package com.iteaj.iot;

import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.event.EventListener;

/**
 * create time: 2022/1/16
 *
 * @author iteaj
 * @since 1.0
 */
@PropertySource("/core.properties")
@EnableConfigurationProperties(IotCoreProperties.class)
public class IotCoreConfiguration implements ApplicationListener<ApplicationEnvironmentPreparedEvent> {

    private final IotCoreProperties properties;

    public IotCoreConfiguration(IotCoreProperties properties) {
        this.properties = properties;

        System.out.println("--------------------------------------------------------------------------------");
        System.out.println("                     STARTING IOT FRAMEWORK OF NETTY (V2.3.0)                    ");
        System.out.println("--------------------------------------------------------------------------------");
    }

    @Bean
    public IotThreadManager iotThreadManager() {
        return IotThreadManager.instance();
    }

    @Override
    public void onApplicationEvent(ApplicationEnvironmentPreparedEvent event) {
        System.out.println(event);
    }
}
